home *** CD-ROM | disk | FTP | other *** search
/ Graphics Plus / Graphics Plus.iso / general / modelers / geomview / source.lha / Geomview / src / bin / sweep_next / Sweep.m < prev   
Text File  |  1993-07-06  |  2KB  |  92 lines

  1.  
  2. #import "Sweep.h"
  3.  
  4. #include <stdio.h>
  5. #include "geom.h"
  6. #include "point3.h"
  7. #include "sweep.h"
  8.  
  9. #define TRAN 0
  10. #define ROT 1
  11. #define RAD 0
  12. #define DEG 1
  13.  
  14. @implementation Sweep
  15.  
  16. - appDidInit:sender
  17. {
  18.     [sweepWindow setAvoidsActivation:YES];
  19.  
  20.     cView = [sweepWindow contentView];
  21.  
  22.     [tranView getFrame:&boxFrame];
  23.     return self;
  24. }
  25.  
  26. - go:sender
  27. {
  28.   Geom *g, *s;
  29.   Point3 pt1, pt2;
  30.  
  31.   printf("(write geometry - targetgeom bare)");
  32.   fflush(stdout);
  33.   g = GeomFLoad(stdin, NULL);
  34.  
  35.   if ([[tranRot selectedCell] tag]==ROT) {
  36.     pt1.x = [rotEnd floatValueAt:0];
  37.     pt1.y = [rotEnd floatValueAt:1];
  38.     pt1.z = [rotEnd floatValueAt:2];
  39.     pt2.x = [rotDir floatValueAt:0];
  40.     pt2.y = [rotDir floatValueAt:1];
  41.     pt2.z = [rotDir floatValueAt:2];
  42.     s = RotationSweep([rotLength floatValue] * 
  43.     (([[radDeg selectedCell] tag] == DEG) ? M_PI / 180.0 : 1.0), 
  44.     &pt1, &pt2, 
  45.     [rotDivisions intValue], g);
  46.   } else {
  47.     pt1.x = [transDir floatValueAt:0];
  48.     pt1.y = [transDir floatValueAt:1];
  49.     pt1.z = [transDir floatValueAt:2];
  50.     s = TranslationSweep([transLength floatValue], &pt1, g);
  51.   }
  52.  
  53.   if (s != NULL) {
  54.     printf("(geometry sweep { ");
  55.     GeomFSave(s, stdout, NULL);
  56.     printf(" } ) ");
  57.     fflush(stdout);
  58.   }
  59.   GeomDelete(g);
  60.   GeomDelete(s);
  61.                
  62.     return self;
  63. }
  64.  
  65. - rotTran:sender
  66. {
  67.     if([[sender selectedCell] tag]==TRAN) {
  68.     if([tranView superview]!=cView) {
  69.         [tranView removeFromSuperview];
  70.         [rotView removeFromSuperview];
  71.         [cView addSubview:tranView];
  72.         [tranView setFrame:&boxFrame];
  73.         [cView display];
  74.     }
  75.     }
  76.  
  77.     else if([[sender selectedCell] tag]==ROT) {
  78.     if([rotView superview]!=cView) {
  79.         [tranView removeFromSuperview];
  80.         [rotView removeFromSuperview];
  81.         [cView addSubview:rotView];
  82.         [rotView setFrame:&boxFrame];
  83.         [cView display];
  84.     }
  85.     }
  86.  
  87.     return self;
  88. }
  89.  
  90.  
  91. @end
  92.